package com.eobard.params;

import com.eobard.config.obfuscate.ObfuscatorConfig;
import com.eobard.enums.RunningEnum;
import com.eobard.utils.RandomExpression;
import com.github.javaparser.ast.body.MethodDeclaration;
import com.github.javaparser.ast.type.Type;

/**
 * @Author: Eobard Gu
 * @Date: 2025-08-07
 * @Description: 方法参数混淆父配置类
 */
public abstract class IMethod {

    public static final int INVALID_PACKAGE_NUM = 2;

    /**
     * 临时的参数类型对象
     **/
    public static class AddTypeInfo {
        public int insertIndex;
        public Type paramsType;
        public String paramName;

        public AddTypeInfo(int insertIndex, Type paramsType, String paramName) {
            this.insertIndex = insertIndex;
            this.paramsType = paramsType;
            this.paramName = paramName;
        }
    }

    /**
     * 临时的参数类型对象
     **/
    public static class StaticMethod {
        public String packageName;
        public String className;
        public MethodDeclaration md;

        public StaticMethod(String packageName, String className, MethodDeclaration md) {
            this.packageName = packageName;
            this.className = className;
            this.md = md;
        }
    }

    //获取LoggerPrint方法体
    public static String getLoggerPrintBody(ObfuscatorConfig config) {
        String androidBody = "{try {Log.d(\"" + RandomExpression.getName() + "\", Arrays.toString(values));}catch (Exception ignored){}}";
        String nonAndroidBody = "{try {logger.finest(\"" + RandomExpression.getName() + "\"+Arrays.toString(values));}catch (Exception ignored){}}";
        return config.getRunningStatus() == RunningEnum.JAVA_PROJECT ? nonAndroidBody : androidBody;
    }

    //获取打印日志的包
    public static String getLoggerImport(ObfuscatorConfig config) {
        String androidImport = "android.util.Log";
        String nonAndroidImport = "java.util.logging.Logger";
        return config.getRunningStatus() == RunningEnum.JAVA_PROJECT ? nonAndroidImport : androidImport;
    }


}
